import { Order } from "@/api/interface/order";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 订单接口
 */

// 分页查询订单
export const getOrderPage = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/page`, params);
};

// 添加订单
export const addOrder = (params: Order.ResOrderData) => {
  return http.post(PORT1 + `/order/add`, params);
};

// 编辑订单
export const updateOrder = (params: Order.ResOrderData) => {
  return http.post(PORT1 + `/order/update`, params);
};

// 删除订单
export const deleteOrder = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/delete`, params);
};

// 查询订单
export const getOrderDetail = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/detail`, params);
};

// 订单状态统计

export const getOrderCountOrderStatus = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/countOrderStatus`, params);
};

// 订单相关人员
export const getOrderRelatedPerson = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/getOrderRelatedPerson`, params);
};

// 筛选条件查询订单
export const getOrderQueryPage = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/query`, params);
};
/**
 * @name 订单文件
 */

// 分页查询订单文件信息
export const getOrderFilesPage = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/files/page`, params);
};

// 添加订单文件信息
export const addOrderFile = (params: Order.ResOrderData) => {
  return http.post(PORT1 + `/order/files/add`, params);
};

// 删除订单方案信息
export const deleteOrderFiles = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/files/delete`, params);
};

/**
 *批量添加订单文件信息
 */
export const addOrderFileBatch = (params: Order.ResOrderData) => {
  return http.post(PORT1 + `/order/files/add/batch`, params);
};
/**
 * @name 订单物料
 */

// 分页查询订单物料
export const getOrderMaterielPage = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/materiel/page`, params);
};

// 添加订单物料
export const addOrderMateriel = (params: Order.ResOrderData) => {
  return http.post(PORT1 + `/order/materiel/add`, params);
};

// 删除订单物料
export const deleteOrderMateriel = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/materiel/delete`, params);
};

// 修改订单物料
export const updateOrderMateriel = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/materiel/update`, params);
};

/**
 * @name 订单跟进信息
 */

// 分页查询订单跟进信息
export const getOrderFollowPage = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/follow/page`, params);
};

// 添加订单跟进信息
export const addOrderFollow = (params: Order.ResOrderData) => {
  return http.post(PORT1 + `/order/follow/add`, params);
};

// 删除订单物料
export const deleteOrderFollow = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/follow/delete`, params);
};

// 修改订单物料
export const updateOrderFollow = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/follow/update`, params);
};

/**
 * @name 订单任务
 */

// 修改订单任务计划开始时间
export const updatePdmOrderTaskPlanStartTime = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/task/updatePdmOrderTaskPlanStartTime`, params);
};

// 修改订单任务计划结束时间

export const updatePdmOrderTaskPlanEndTime = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/task/updatePdmOrderTaskPlanEndTime`, params);
};

// 修改订单任务实际开始时间
export const updatePdmOrderTaskStartTime = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/task/updatePdmOrderTaskStartTime`, params);
};

// 修改订单任务实际结束时间
export const updatePdmOrderTaskEndTime = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/task/updatePdmOrderTaskEndTime`, params);
};

// 修改订单任务设计人员

export const updatePdmOrderTaskDesigner = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/task/updatePdmOrderTaskDesigner`, params);
};

// 修改订单任务
export const updateOrderTask = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/task/update`, params);
};

// 查询订单任务变更历史

export const getChangeHistoryByOrderTaskId = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/task/change/history/getChangeHistoryByOrderTaskId`, params);
};

// 查询全部可用的项目订单

export const getOrderAvailable = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/project/available`, params);
};

// 编辑订单

export const getOrderUpdate = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/update`, params, { noLoading: true });
};

// 订单日志

export const getOrderLogQuery = (params: Order.ReqOrder) => {
  return http.get(PORT1 + `/order/log/query`, params);
};

// 重新订单审批（编辑订单）
export const getOrderReapproval = (params: Order.ReqOrder) => {
  return http.post(PORT1 + `/order/reapproval`, params, { noLoading: true });
};
